<template>
  <div class="dashboard-container">
    <!-- 顶部导航栏 -->
    <header class="dashboard-header">
      <div class="logo">
        <span class="logo-icon">📊</span>
        <span class="logo-text">数据洞察中心</span>
      </div>
      <div class="header-controls">
        <div class="time-display">{{ currentTime }}</div>
        <button class="refresh-btn" @click="refreshData" :class="{ 'refreshing': isRefreshing }">
          <i class="refresh-icon">🔄</i>
          <span class="refresh-text">刷新数据</span>
        </button>
      </div>
    </header>

    <!-- 主内容区 -->
    <main class="ju" v-if="isMounted" :class="{ loaded: isAnimationLoaded }">
      <!-- 状态卡片 -->
      <div class="status-cards">
        <div class="status-card" :class="{ 'pulse-glow': status === 'optimal' }">
          <div class="list" style="margin: 0 auto;text-align: center;">
            <img src="./image/renwuwanchengkuang.png" alt="" width="40px" height="40px">
            <div class="status-info" style="text-align: center;">
              <div class="status-title" style="margin: 10px 0;">系统状态</div>
              <div class="status-value">运行正常</div>
            </div>
          </div>

          <div class="status-meta">最后检查: 刚刚</div>
        </div>

        <div class="status-card">
          <div class="list" style="margin: 0 auto;text-align: center;">
            <img src="./image/mianxing-shujuzengchang.png" alt="" width="40px" height="40px">
            <div class="status-info" style="text-align: center;">
              <div class="status-title" style="margin: 10px 0;">今日数据增长</div>
              <div class="status-value">+12.5%</div>
            </div>
          </div>

          <div class="status-meta">较昨日</div>
        </div>

        <div class="status-card">
          <div class="list" style="margin: 0 auto;text-align: center;">
            <img src="./image/jixiaorenwuwancheng.png" alt="" width="40px" height="40px">
             <div class="status-info" style="text-align: center;">
            <div class="status-title" style="margin: 10px 0;">任务完成率</div>
            <div class="status-value">92%</div>
          </div>
          </div>
         
          <div class="status-meta">目标: 90%</div>
        </div>
      </div>

      <!-- 图表区域 -->
      <el-row :gutter="20" class="charts-row top-row">
        <!-- 平台数据分布 -->
        <el-col :span="12">
          <el-card class="chart-card platform-card">
            <template #header>
              <div class="card-header">
                <span class="title-platform">平台数据分布</span>
                <el-select v-model="platformChartType" size="small" class="chart-select">
                  <el-option label="评论数据" value="comments" />
                  <el-option label="点赞数据" value="likes" />
                  <el-option label="转发数据" value="shares" />
                </el-select>
              </div>
            </template>
            <div ref="platformChart" class="chart-container"></div>
          </el-card>
        </el-col>

        <!-- 数据趋势图 -->
        <el-col :span="12">
          <el-card class="chart-card trend-card">
            <template #header>
              <div class="card-header">
                <span class="title-trend">数据趋势</span>
                <el-radio-group v-model="trendTimeRange" size="small" class="time-range-selector">
                  <el-radio-button label="week">周</el-radio-button>
                  <el-radio-button label="month">月</el-radio-button>
                </el-radio-group>
              </div>
            </template>
            <div ref="trendChart" class="chart-container"></div>
          </el-card>
        </el-col>
      </el-row>

      <!-- 下方区域 -->
      <el-row ref="bottomChartsContainer" :gutter="20" class="charts-row bottom-row"
        :style="{ visibility: bottomContentVisible ? 'visible' : 'hidden' }">
        <!-- 任务执行状态 -->
        <el-col :span="8">
          <el-card class="chart-card task-card">
            <template #header>
              <div class="card-header">
                <span class="title-task">任务执行状态</span>
              </div>
            </template>
            <div ref="taskStatusChart" class="chart-container"></div>
          </el-card>
        </el-col>

        <!-- 热门内容分析 -->
        <el-col :span="8">
          <el-card class="chart-card hot-content-card">
            <template #header>
              <div class="card-header">
                <span class="title-hot">热门内容分析</span>
              </div>
            </template>
            <div ref="hotContentChart" class="chart-container"></div>
          </el-card>
        </el-col>

        <!-- 账号健康度 -->
        <el-col :span="8">
          <el-card class="chart-card health-card">
            <template #header>
              <div class="card-header">
                <span class="title-health">账号健康度</span>
              </div>
            </template>
            <div ref="accountHealthChart" class="chart-container"></div>
          </el-card>
        </el-col>
      </el-row>
    </main>

    <!-- 页脚 -->
    <footer class="dashboard-footer" :style="{ visibility: bottomContentVisible ? 'visible' : 'hidden' }">
      <div class="footer-info">数据洞察中心 © 2025 | 最后更新: {{ lastUpdated }}</div>
      <div class="footer-links">
        <a href="#" class="footer-link">帮助中心</a>
        <a href="#" class="footer-link">数据说明</a>
        <a href="#" class="footer-link">联系我们</a>
      </div>
    </footer>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted, nextTick, watchEffect } from 'vue'
import { useIntersectionObserver } from '@vueuse/core' // 引入懒加载工具

// 控制组件是否渲染
const isMounted = ref(false)
// 控制下方内容是否显示（延迟加载）
const bottomContentVisible = ref(false)
// 控制动画是否加载
const isAnimationLoaded = ref(false)

// 图表实例引用
const platformChart = ref(null)
const trendChart = ref(null)
const taskStatusChart = ref(null)
const hotContentChart = ref(null)
const accountHealthChart = ref(null)
const bottomChartsContainer = ref(null)

// 图表实例存储
const chartInstances = ref({
  platform: null,
  trend: null,
  taskStatus: null,
  hotContent: null,
  accountHealth: null
})

// 控制变量
const platformChartType = ref('comments')
const trendTimeRange = ref('week')
const currentTime = ref('')
const lastUpdated = ref('')
const status = ref('optimal')
const isRefreshing = ref(false)
// 存储动态加载的echarts实例
const echartsInstance = ref(null)

// 更新时间显示
const updateTimeDisplay = () => {
  const now = new Date()
  currentTime.value = now.toLocaleTimeString('zh-CN', {
    hour: '2-digit',
    minute: '2-digit',
    second: '2-digit'
  })

  // 格式化最后更新时间
  lastUpdated.value = now.toLocaleString('zh-CN', {
    month: 'short',
    day: 'numeric',
    hour: '2-digit',
    minute: '2-digit'
  })
}

// 动态加载ECharts函数
const loadECharts = async () => {
  if (echartsInstance.value) return echartsInstance.value

  try {
    // 动态导入ECharts核心模块
    const echarts = await import('echarts/core')
    const { PieChart, LineChart, GaugeChart, BarChart, RadarChart } = await import('echarts/charts')
    const { GridComponent, TooltipComponent, LegendComponent, RadarComponent } = await import('echarts/components')
    const { CanvasRenderer } = await import('echarts/renderers')

    // 注册所需模块
    echarts.use([
      PieChart, LineChart, GaugeChart, BarChart, RadarChart,
      GridComponent, TooltipComponent, LegendComponent, RadarComponent,
      CanvasRenderer
    ])

    echartsInstance.value = echarts
    return echarts
  } catch (error) {
    console.error('ECharts加载失败:', error)
    throw error
  }
}

// 刷新数据功能（优化：仅更新数据不销毁实例）
const refreshData = () => {
  if (isRefreshing.value || !echartsInstance.value) return

  isRefreshing.value = true

  // 模拟数据刷新
  setTimeout(() => {
    updateTimeDisplay()
    updateChartsData(false) // 刷新时加载完整数据
    isRefreshing.value = false
  }, 1000)
}

// 处理窗口大小变化的函数
const handleResize = () => {
  Object.values(chartInstances.value).forEach(instance => {
    if (instance && !instance.isDisposed()) {
      instance.resize()
    }
  })
}

// 销毁单个图表实例的工具函数
const disposeChart = (instance) => {
  if (instance && typeof instance.isDisposed === 'function' && !instance.isDisposed()) {
    try {
      instance.off()
      instance.clear()
      instance.dispose()
    } catch (e) {
      console.warn('销毁图表实例时出错:', e)
    }
  }
}

// 批量销毁所有图表
const disposeAllCharts = () => {
  Object.values(chartInstances.value).forEach(instance => {
    disposeChart(instance)
  })
  chartInstances.value = {}
}

onMounted(async () => {
  // 初始化时间显示
  updateTimeDisplay()
  setInterval(updateTimeDisplay, 1000)

  try {
    // 先加载ECharts
    const echarts = await loadECharts()

    // 延迟渲染组件，优化初始加载
    setTimeout(() => {
      isMounted.value = true

      nextTick(() => {
        // 初始化顶部图表（首屏优先）
        initTopCharts(echarts, true) // 初始加载简化数据

        // 监听底部图表容器可见性，实现懒加载
        const { stop } = useIntersectionObserver(
          bottomChartsContainer,
          ([{ isIntersecting }]) => {
            if (isIntersecting && echartsInstance.value) {
              initBottomCharts(echartsInstance.value, true) // 初始加载简化数据
              bottomContentVisible.value = true
              stop() // 只监听一次
            }
          },
          { threshold: 0.1 } // 可见面积达10%时触发
        )

        window.addEventListener('resize', handleResize)

        // 启动动画
        setTimeout(() => {
          isAnimationLoaded.value = true
        }, 500)
      })
    }, 100)
  } catch (error) {
    console.error('初始化失败:', error)
  }
})

// 初始化顶部图表（首屏优先）
const initTopCharts = (echarts, isSimplified = false) => {
  // 平台数据分布图（饼图）
  if (platformChart.value) {
    chartInstances.value.platform = echarts.init(platformChart.value)
    chartInstances.value.platform.setOption(getPlatformChartOption(isSimplified))
    chartInstances.value.platform.dispatchAction({
      type: 'showTip',
      seriesIndex: 0,
      dataIndex: 0
    })
  }

  // 数据趋势图（折线图）
  if (trendChart.value) {
    chartInstances.value.trend = echarts.init(trendChart.value)
    chartInstances.value.trend.setOption(getTrendChartOption(isSimplified))
  }
}

// 初始化底部图表（延迟加载）
const initBottomCharts = (echarts, isSimplified = false) => {
  // 任务执行状态图（仪表盘）
  if (taskStatusChart.value) {
    chartInstances.value.taskStatus = echarts.init(taskStatusChart.value)
    chartInstances.value.taskStatus.setOption(getTaskStatusOption(isSimplified))
  }

  // 热门内容分析图（条形图）
  if (hotContentChart.value) {
    chartInstances.value.hotContent = echarts.init(hotContentChart.value)
    chartInstances.value.hotContent.setOption(getHotContentOption(isSimplified))
  }

  // 账号健康度图（雷达图）
  if (accountHealthChart.value) {
    chartInstances.value.accountHealth = echarts.init(accountHealthChart.value)
    chartInstances.value.accountHealth.setOption(getAccountHealthOption(isSimplified))
  }
}

// 更新图表数据（优化：不销毁实例，仅更新数据）
const updateChartsData = (isSimplified = false) => {
  chartInstances.value.platform?.setOption(getPlatformChartOption(isSimplified))
  chartInstances.value.trend?.setOption(getTrendChartOption(isSimplified))
  chartInstances.value.taskStatus?.setOption(getTaskStatusOption(isSimplified))
  chartInstances.value.hotContent?.setOption(getHotContentOption(isSimplified))
  chartInstances.value.accountHealth?.setOption(getAccountHealthOption(isSimplified))
}

// 图表配置项（修复：关联控制变量）
const getPlatformChartOption = (isSimplified = false) => {
  // 根据选中类型切换数据
  const dataMap = {
    comments: [
      { value: 1048, name: '抖音' },
      { value: 735, name: '快手' },
      { value: 580, name: '小红书' },
      { value: 484, name: '微博' },
      { value: 300, name: '其他' }
    ],
    likes: [
      { value: 1840, name: '抖音' },
      { value: 935, name: '快手' },
      { value: 780, name: '小红书' },
      { value: 520, name: '微博' },
      { value: 250, name: '其他' }
    ],
    shares: [
      { value: 640, name: '抖音' },
      { value: 435, name: '快手' },
      { value: 320, name: '小红书' },
      { value: 880, name: '微博' },
      { value: 180, name: '其他' }
    ]
  }

  // 简化模式只显示前3项数据
  const data = isSimplified
    ? dataMap[platformChartType.value].slice(0, 3)
    : dataMap[platformChartType.value]

  return ({
    color: ['#FF5252', '#FF9800', '#FFEB3B', '#4CAF50', '#2196F3'],
    tooltip: {
      trigger: 'item',
      formatter: '{a} <br/>{b}: {c} ({d}%)',
      backgroundColor: 'rgba(10, 0, 40, 0.9)',
      borderColor: '#ff00ff',
      borderWidth: 1,
      textStyle: { color: '#fff' }
    },
    legend: {
      orient: 'vertical',
      right: 10,
      top: 'center',
      textStyle: { color: 'rgba(255, 255, 255, 0.8)' }
    },
    series: [{
      name: '平台分布',
      type: 'pie',
      radius: ['50%', '70%'],
      avoidLabelOverlap: false,
      itemStyle: {
        borderRadius: 10,
        borderColor: '#fff',
        borderWidth: 2,
        shadowBlur: 10,
        shadowColor: 'rgba(0, 0, 0, 0.3)'
      },
      label: { show: false },
      emphasis: {
        label: { show: true, fontSize: '20', fontWeight: 'bold', color: '#fff' },
        itemStyle: {
          shadowBlur: 20,
          shadowColor: 'rgba(255, 0, 255, 0.5)'
        }
      },
      data: data,
      animationDuration: isSimplified ? 100 : 500, // 简化模式动画更快
      animationEasingUpdate: 'cubicOut'
    }]
  })
}

const getTrendChartOption = (isSimplified = false) => {
  // 根据时间范围切换数据
  const isWeek = trendTimeRange.value === 'week'
  const xAxisData = isWeek
    ? ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    : ['1月', '2月', '3月', '4月', '5月', '6月']

  // 简化模式减少数据点
  const simplifiedXData = isWeek
    ? ['周一', '周三', '周五', '周日']
    : ['1月', '3月', '5月']

  // 周/月数据区分
  const trendData = {
    week: {
      抓取数据量: [820, 932, 901, 934, 1290, 1330, 1320],
      发布数量: [120, 132, 101, 134, 90, 230, 210],
      互动量: [320, 332, 301, 334, 390, 330, 320]
    },
    month: {
      抓取数据量: [3200, 3900, 4200, 5100, 4900, 5800],
      发布数量: [420, 530, 490, 630, 590, 680],
      互动量: [1200, 1500, 1300, 1700, 1600, 1900]
    }
  }

  // 简化数据处理
  const processData = (data) => {
    if (!isSimplified) return data
    // 每隔一个取一个数据点
    return data.filter((_, index) => index % 2 === 0)
  }

  return ({
    color: ['#2196F3', '#4CAF50', '#F44336'],
    tooltip: {
      trigger: 'axis',
      backgroundColor: 'rgba(10, 0, 40, 0.9)',
      borderColor: '#00fff9',
      borderWidth: 1,
      textStyle: { color: '#fff' }
    },
    legend: {
      data: ['抓取数据量', '发布数量', '互动量'],
      textStyle: { color: 'rgba(255, 255, 255, 0.8)' }
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      data: isSimplified ? simplifiedXData : xAxisData,
      axisLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.3)' } },
      axisLabel: { color: 'rgba(255, 255, 255, 0.7)' }
    },
    yAxis: {
      type: 'value',
      axisLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.3)' } },
      axisLabel: { color: 'rgba(255, 255, 255, 0.7)' },
      splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.1)' } }
    },
    series: [
      {
        name: '抓取数据量',
        type: 'line',
        smooth: true,
        lineStyle: { width: 3 },
        itemStyle: {
          radius: 6,
          borderWidth: 2,
          borderColor: '#fff'
        },
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [{
              offset: 0, color: 'rgba(33, 150, 243, 0.3)'
            }, {
              offset: 1, color: 'rgba(33, 150, 243, 0)'
            }]
          }
        },
        data: processData(trendData[trendTimeRange.value]['抓取数据量'])
      },
      {
        name: '发布数量',
        type: 'line',
        smooth: true,
        lineStyle: { width: 3 },
        itemStyle: {
          radius: 6,
          borderWidth: 2,
          borderColor: '#fff'
        },
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [{
              offset: 0, color: 'rgba(76, 175, 80, 0.3)'
            }, {
              offset: 1, color: 'rgba(76, 175, 80, 0)'
            }]
          }
        },
        data: processData(trendData[trendTimeRange.value]['发布数量'])
      },
      {
        name: '互动量',
        type: 'line',
        smooth: true,
        lineStyle: { width: 3 },
        itemStyle: {
          radius: 6,
          borderWidth: 2,
          borderColor: '#fff'
        },
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [{
              offset: 0, color: 'rgba(244, 67, 54, 0.3)'
            }, {
              offset: 1, color: 'rgba(244, 67, 54, 0)'
            }]
          }
        },
        data: processData(trendData[trendTimeRange.value]['互动量'])
      }
    ],
    animationDuration: isSimplified ? 100 : 500
  })
}

const getTaskStatusOption = (isSimplified = false) => ({
  series: [{
    type: 'gauge',
    progress: { show: true, width: 18, itemStyle: { color: '#fff700' } },
    axisLine: {
      lineStyle: {
        width: 18,
        color: [[0.6, 'rgba(255, 255, 255, 0.2)'], [1, 'rgba(255, 247, 0, 0.6)']]
      }
    },
    axisTick: { show: false },
    splitLine: {
      length: 15,
      lineStyle: { width: 2, color: 'rgba(255, 255, 255, 0.3)' }
    },
    axisLabel: { color: 'rgba(255, 255, 255, 0.7)' },
    pointer: {
      length: '75%',
      width: 16,
      offsetCenter: [0, '5%'],
      itemStyle: { color: '#fff700' }
    },
    detail: {
      valueAnimation: !isSimplified, // 简化模式关闭动画
      formatter: '{value}%',
      color: '#fff700',
      fontSize: 24,
      fontWeight: 'bold'
    },
    title: {
      color: 'rgba(255, 255, 255, 0.7)',
      fontSize: 14
    },
    data: [{ value: 92, name: '任务完成率' }],
    animationDuration: isSimplified ? 500 : 2000
  }]
})

const getHotContentOption = (isSimplified = false) => ({
  tooltip: {
    trigger: 'axis',
    axisPointer: { type: 'shadow' },
    backgroundColor: 'rgba(10, 0, 40, 0.9)',
    borderColor: '#ff9900',
    borderWidth: 1,
    textStyle: { color: '#fff' }
  },
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'value',
    axisLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.3)' } },
    axisLabel: { color: 'rgba(255, 255, 255, 0.7)' },
    splitLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.1)' } }
  },
  yAxis: {
    type: 'category',
    // 简化模式只显示前3项
    data: isSimplified
      ? ['产品评测', '使用教程', '行业分析']
      : ['产品评测', '使用教程', '行业分析', '用户反馈', '活动推广'],
    axisLine: { lineStyle: { color: 'rgba(255, 255, 255, 0.3)' } },
    axisLabel: { color: 'rgba(255, 255, 255, 0.7)' }
  },
  series: [{
    name: '播放量',
    type: 'bar',
    // 简化模式只显示前3项数据
    data: isSimplified ? [320, 302, 301] : [320, 302, 301, 334, 390],
    itemStyle: {
      color: new echartsInstance.value.graphic.LinearGradient(0, 0, 1, 0, [
        { offset: 0, color: '#ff6600' },
        { offset: 1, color: '#ffcc00' }
      ]),
      borderRadius: [0, 6, 6, 0],
      shadowBlur: 10,
      shadowColor: 'rgba(255, 153, 0, 0.5)'
    },
    emphasis: {
      itemStyle: {
        shadowBlur: 20,
        shadowColor: 'rgba(255, 153, 0, 0.8)'
      }
    },
    animationDuration: isSimplified ? 500 : 1000,
    animationEasing: 'elasticOut'
  }]
})

const getAccountHealthOption = (isSimplified = false) => ({
  radar: {
    indicator: [
      { name: '活跃度', max: 100 },
      { name: '粉丝增长', max: 100 },
      { name: '互动率', max: 100 },
      { name: '内容质量', max: 100 },
      { name: '合规性', max: 100 }
    ],
    splitArea: {
      areaStyle: {
        color: ['rgba(255, 255, 255, 0.05)', 'rgba(255, 255, 255, 0.1)']
      }
    },
    axisLine: {
      lineStyle: {
        color: 'rgba(255, 255, 255, 0.3)'
      }
    },
    splitLine: {
      lineStyle: {
        color: 'rgba(255, 255, 255, 0.2)'
      }
    },
    name: {
      textStyle: {
        color: 'rgba(255, 255, 255, 0.8)'
      }
    }
  },
  series: [{
    type: 'radar',
    symbol: 'circle',
    symbolSize: 8,
    lineStyle: {
      width: 3,
      color: '#9d00ff'
    },
    areaStyle: {
      color: {
        type: 'radial',
        x: 0.5,
        y: 0.5,
        r: 0.8,
        colorStops: [{
          offset: 0, color: 'rgba(157, 0, 255, 0.4)'
        }, {
          offset: 1, color: 'rgba(157, 0, 255, 0)'
        }]
      }
    },
    itemStyle: {
      color: '#9d00ff',
      borderColor: '#fff',
      borderWidth: 2
    },
    data: [{
      value: [85, 90, 75, 95, 88],
      name: '账号健康度'
    }],
    animationDuration: isSimplified ? 500 : 2000
  }]
})

// 页面卸载前清理资源
onUnmounted(() => {
  isMounted.value = false
  disposeAllCharts()
  window.removeEventListener('resize', handleResize)
  echartsInstance.value = null
})

// 监听图表类型切换
watchEffect(() => {
  if (chartInstances.value.platform) {
    chartInstances.value.platform.setOption(getPlatformChartOption())
  }
})

watchEffect(() => {
  if (chartInstances.value.trend) {
    chartInstances.value.trend.setOption(getTrendChartOption())
  }
})
</script>
<style lang="scss" scoped>
// 核心霓虹色彩体系
$neon-pink: #ff00ff;
$neon-cyan: #00fff9;
$neon-purple: #9d00ff;
$neon-yellow: #fff700;
$neon-orange: #ff9900;
$dark-bg: #000112;
$panel-bg: rgba(10, 0, 40, 0.85);

// 发光效果
$glow-pink: 0 0 5px $neon-pink, 0 0 10px $neon-pink;
$glow-cyan: 0 0 5px $neon-cyan, 0 0 10px $neon-cyan;
$glow-purple: 0 0 5px $neon-purple, 0 0 10px $neon-purple;
$glow-yellow: 0 0 5px $neon-yellow, 0 0 10px $neon-yellow;
$glow-orange: 0 0 5px $neon-orange, 0 0 10px $neon-orange;

// 主容器
.dashboard-container {
  min-height: 100vh;
  background-color: $dark-bg;
  color: #fff;
  overflow-x: hidden;
}

// 顶部导航
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px;
  background: linear-gradient(180deg, rgba(10, 0, 40, 0.9) 0%, rgba(0, 0, 10, 0.8) 100%);
  border-bottom: 1px solid rgba(0, 255, 249, 0.2);
  box-shadow: 0 2px 15px rgba(0, 255, 249, 0.1);
  position: relative;
  z-index: 100;

  .logo {
    display: flex;
    align-items: center;
    gap: 12px;

    .logo-icon {
      font-size: 24px;
      text-shadow: $glow-cyan;
    }

    .logo-text {
      font-size: 20px;
      font-weight: 700;
      color: $neon-cyan;
      text-shadow: $glow-cyan;
      letter-spacing: 1px;
    }
  }

  .header-controls {
    display: flex;
    align-items: center;
    gap: 20px;

    .time-display {
      color: rgba(255, 255, 255, 0.8);
      font-family: 'Consolas', monospace;
      padding: 5px 10px;
      background: rgba(255, 255, 255, 0.05);
      border-radius: 4px;
      border: 1px solid rgba(0, 255, 249, 0.2);
    }

    .refresh-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 14px;
      background: rgba(255, 0, 255, 0.1);
      border: 1px solid $neon-pink;
      border-radius: 4px;
      color: $neon-pink;
      cursor: pointer;
      transition: all 0.3s;

      &:hover {
        background: rgba(255, 0, 255, 0.2);
        box-shadow: $glow-pink;
      }

      &:active {
        transform: translateY(1px);
      }

      .refresh-icon {
        transition: transform 0.5s ease;
      }

      &.refreshing {
        .refresh-icon {
          animation: spin 1s linear infinite;
        }
      }
    }
  }
}

// 主内容区
.ju {
  margin: 20px;
  padding: 30px;
  position: relative;
  background:
    linear-gradient(135deg, #000120 0%, #00000d 100%),
    radial-gradient(circle at 20% 40%, rgba(255, 0, 255, 0.1) 0%, transparent 60%),
    radial-gradient(circle at 80% 60%, rgba(0, 255, 249, 0.1) 0%, transparent 60%);
  background-blend-mode: screen;
  background-size: 100% 100%, 100% 100%, 100% 100%;
  border-radius: 16px;
  border: 1px solid rgba(0, 255, 249, 0.2);
  box-shadow:
    0 0 30px rgba(0, 0, 0, 0.5),
    inset 0 0 20px rgba(0, 255, 249, 0.05);
  z-index: 1;
  animation: none; // 默认关闭动画

  &.loaded {
    animation: subtle-pulse 8s infinite alternate; // 加载完成后启动动画
  }
}

// 状态卡片
.status-cards {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;

  .status-card {
    flex: 1;
    background: $panel-bg;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
    will-change: transform, box-shadow; // 优化动画性能

    &:hover {
      transform: translateY(-5px);
      box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    }

    .status-icon {
      font-size: 24px;
      margin-bottom: 10px;
    }

    .status-info {
      flex: 1;

      .status-title {
        color: rgba(255, 255, 255, 0.6);
        font-size: 14px;
        margin-bottom: 5px;
      }

      .status-value {
        font-size: 24px;
        font-weight: 700;
      }
    }

    .status-meta {
      color: rgba(255, 255, 255, 0.4);
      font-size: 12px;
      margin-top: 10px;
      text-align: right;
    }
  }
}

// 图表行容器
.charts-row {
  margin-bottom: 30px;
  position: relative;
  z-index: 10;

  &:not(:last-child):after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 5%;
    right: 5%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 255, 249, 0.3), transparent);
    z-index: 5;
  }
}

// 卡片标题
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  position: relative;
  z-index: 15;

  .chart-select,
  .time-range-selector {
    z-index: 20;
  }

  span {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
    position: relative;
    padding-left: 30px;

    &:before {
      content: '0' counter(card-counter);
      counter-increment: card-counter;
      position: absolute;
      left: 0;
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      border-radius: 4px;
      font-family: 'Consolas', monospace;
    }
  }

  .title-platform {
    color: $neon-pink;
    text-shadow: 0 0 5px rgba(255, 0, 255, 0.5);

    &:before {
      border: 1px solid $neon-pink;
      color: $neon-pink;
      box-shadow: 0 0 5px rgba(255, 0, 255, 0.5);
    }
  }

  .title-trend {
    color: $neon-cyan;
    text-shadow: 0 0 5px rgba(0, 255, 249, 0.5);

    &:before {
      border: 1px solid $neon-cyan;
      color: $neon-cyan;
      box-shadow: 0 0 5px rgba(0, 255, 249, 0.5);
    }
  }

  .title-task {
    color: $neon-yellow;
    text-shadow: 0 0 5px rgba(255, 247, 0, 0.5);

    &:before {
      border: 1px solid $neon-yellow;
      color: $neon-yellow;
      box-shadow: 0 0 5px rgba(255, 247, 0, 0.5);
    }
  }

  .title-hot {
    color: $neon-orange;
    text-shadow: 0 0 5px rgba(255, 153, 0, 0.5);

    &:before {
      border: 1px solid $neon-orange;
      color: $neon-orange;
      box-shadow: 0 0 5px rgba(255, 153, 0, 0.5);
    }
  }

  .title-health {
    color: $neon-purple;
    text-shadow: 0 0 5px rgba(157, 0, 255, 0.5);

    &:before {
      border: 1px solid $neon-purple;
      color: $neon-purple;
      box-shadow: 0 0 5px rgba(157, 0, 255, 0.5);
    }
  }
}

// 图表卡片样式
.chart-card {
  border: none;
  border-radius: 12px;
  background: $panel-bg;
  backdrop-filter: blur(10px);
  box-shadow:
    0 5px 15px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(255, 0, 255, 0.05);
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease;

  &:hover {
    transform: translateY(-5px);
    box-shadow:
      0 10px 25px rgba(0, 0, 0, 0.4),
      0 0 30px currentColor;
  }

  &:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0.7;
  }

  .el-card__header {
    background: rgba(10, 0, 40, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px 20px;
  }

  .el-card__body {
    padding: 20px;
  }
}

// 不同卡片的顶部装饰线颜色
.platform-card {
  color: $neon-pink;

  &:before {
    background: linear-gradient(90deg, $neon-pink, transparent);
  }
}

.trend-card {
  color: $neon-cyan;

  &:before {
    background: linear-gradient(90deg, $neon-cyan, transparent);
  }
}

.task-card {
  color: $neon-yellow;

  &:before {
    background: linear-gradient(90deg, $neon-yellow, transparent);
  }
}

.hot-content-card {
  color: $neon-orange;

  &:before {
    background: linear-gradient(90deg, $neon-orange, transparent);
  }
}

.health-card {
  color: $neon-purple;

  &:before {
    background: linear-gradient(90deg, $neon-purple, transparent);
  }
}

// 图表容器
.chart-container {
  width: 100%;
  height: 300px;
  min-height: 300px;
  position: relative;
}

// 页脚样式
.dashboard-footer {
  padding: 15px 30px;
  background: linear-gradient(0deg, rgba(10, 0, 40, 0.9) 0%, rgba(0, 0, 10, 0.8) 100%);
  border-top: 1px solid rgba(0, 255, 249, 0.2);
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;

  .footer-links {
    display: flex;
    gap: 20px;

    .footer-link {
      color: rgba(255, 255, 255, 0.5);
      text-decoration: none;
      transition: color 0.3s;

      &:hover {
        color: $neon-cyan;
        text-shadow: 0 0 5px rgba(0, 255, 249, 0.5);
      }
    }
  }
}

// 交互元素样式
.el-radio-button__inner {
  color: rgba(255, 255, 255, 0.7) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  background: rgba(255, 255, 255, 0.05) !important;
  transition: all 0.3s !important;

  &:hover {
    border-color: currentColor !important;
    color: currentColor !important;
  }
}

.el-radio-button__orig-radio:checked+.el-radio-button__inner {
  color: currentColor !important;
  border-color: currentColor !important;
  background: rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 0 8px currentColor !important;
}

.el-select {
  .el-input {
    .el-input__inner {
      background: rgba(255, 255, 255, 0.05) !important;
      border-color: rgba(255, 255, 255, 0.2) !important;
      color: rgba(255, 255, 255, 0.7) !important;
    }
  }
}

.el-select-dropdown {
  background: rgba(10, 0, 40, 0.95) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;

  .el-select-dropdown__item {
    color: rgba(255, 255, 255, 0.7) !important;

    &:hover {
      background: rgba(255, 255, 255, 0.1) !important;
      color: currentColor !important;
    }

    &.selected {
      background: rgba(255, 255, 255, 0.15) !important;
      color: currentColor !important;
    }
  }
}

// 动画效果
@keyframes subtle-pulse {
  0% {
    box-shadow:
      0 0 30px rgba(0, 0, 0, 0.5),
      inset 0 0 20px rgba(0, 255, 249, 0.05);
  }

  100% {
    box-shadow:
      0 0 35px rgba(0, 0, 0, 0.5),
      0 0 40px rgba(157, 0, 255, 0.1),
      inset 0 0 20px rgba(0, 255, 249, 0.08);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 10px rgba(76, 175, 80, 0.3);
  }

  50% {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 20px rgba(76, 175, 80, 0.5);
  }

  100% {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3), 0 0 10px rgba(76, 175, 80, 0.3);
  }
}

// 响应式优化
@media screen and (max-width: 1200px) {
  .status-cards {
    flex-direction: column;
  }

  .charts-row {
    .el-col {
      &:not(:last-child) {
        margin-bottom: 20px;
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .dashboard-header {
    padding: 10px 15px;

    .logo-text {
      font-size: 16px;
    }

    .header-controls {
      gap: 10px;

      .refresh-text {
        display: none;
      }
    }
  }

  .ju {
    margin: 10px;
    padding: 15px;
  }

  .dashboard-footer {
    flex-direction: column;
    gap: 10px;
    text-align: center;
    padding: 15px;
  }
}
</style>